﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;

namespace WpfMqttAnalyzeApp.ValueConverter
{
    public class TabIndexConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int index = (int)value;
            bool show = false;
            if (Int32.TryParse(parameter.ToString(), out int itemIndex))
            {
                show = (index == itemIndex);
            }
            return show;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool show = (bool)value;
            if (Int32.TryParse(parameter.ToString(), out int itemIndex))
            {
                return itemIndex;
            }
            return DependencyProperty.UnsetValue;
        }
    }
}
